package com.admin.bank.controller;

import com.admin.bank.service.DepositRecordService;
import com.admin.bank.service.DepositService;
import com.client.model.vo.common.Result;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @Author：刘文举
 * @DateTime： 2024/4/2 11:52
 * @PackageName: com.service.bank.controller
 * @ClassName: DeposControoler
 */

//存款管理
@RequestMapping("/airui/api/deposit")
@RestController
@Tag(name = "存款管理")
public class DepositController {



    @Autowired
    private DepositService depositService;

    @Autowired
    private DepositRecordService depositRecordService;

    //活期转定期

    /**
     * 返回页面当前卡号的活期存款
     * 参数：
     * bankCard: 卡号
     * @return
     */
    @GetMapping("/findByBankCard")
    @Operation(summary = "返回卡号活期存款")
    public Result deposToDepos(@RequestParam("bankCard")String bankCard){
        //返回页面数据
        return depositService.findDeposToType(bankCard);
    }

    @GetMapping("/findFixed")
    @Operation(summary = "返回卡号所有定期存款")
    public Result deposToFixe(@RequestParam("bankCard")String bankCard){
        //返回页面数据
        return depositService.findDeposToFxiedType(bankCard);
    }

    /**
     * 活期转定期
     * @param bankCard
     * @param did
     * @return
     * 参数:
     * bankCard:卡号
     * type id:存款类型id
     * 转换金额：price
     *
     */
    @PostMapping("currentTofixed")
    @Operation(summary = "活期转定期")
    public Result currentTofixed(String bankCard, Long did, BigDecimal price){
       //存款  活期转定期
      return   depositService.currentTofixed(bankCard,did,price);
    }

    /**
     * 定期转活期
     */
    @PostMapping("fixedToCurrent")
    @Operation(summary = "定期存款转活期存款")
    public Result fixedToCurrent(String bankCard,Long depositid, BigDecimal price){
        //存款 定期转活期
        return depositService.fixedToCurrent(bankCard,depositid,price);
    }

    /**
     * 用户确认申请
     */
    @PostMapping("confirm")
    @Operation(summary = "用户提交活期转定期申请")
    public Result confirm(String bankCard, Long did, BigDecimal price,String payPassword){
       return depositService.confirm(bankCard,did,price,payPassword);

    }

    @PostMapping("confirmFixed")
    @Operation(summary = "用户提交定期转活期申请")
    public Result confirmfixed(String bankCard, Long depositid, BigDecimal price,String payPassword){
        return depositService.confirmfixed(bankCard,depositid,price,payPassword);

    }









}
